import sys

from PyQt5.QtCore import QDate
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton, QFrame, QVBoxLayout, QHBoxLayout, \
    QCheckBox, QSlider, QProgressBar, QCalendarWidget

'''
QCalendarWidget()
获取选择的日期 myCal.clicked[QDate].connect(self.myDo)
print(d.toString(1))
self.lb1.setText(d.toString('yyyy年MM月dd日'))
'''


class MyClass(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('刘金玉编程')
        self.setGeometry(800, 370, 400, 300)

        myCal = QCalendarWidget()
        self.lb1 = QLabel('日期')
        self.lb1.setFont(QFont('', 20))
        myCal.clicked[QDate].connect(self.myDo)

        vlo = QVBoxLayout(self)
        vlo.addWidget(myCal)
        vlo.addWidget(self.lb1)

        self.show()

    def myDo(self, d):
        print(d.toString(1))
        self.lb1.setText(d.toString('yyyy年MM月dd日'))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    myf = MyClass()
    app.exec_()
